package com.easyfun.healthmagicbox.comm;

import java.util.HashMap;
import java.util.Map;

import org.json.JSONObject;

import android.content.Context;

import com.easyfun.healthmagicbox.ormlite.ServerResponseCode;
import com.easyfun.healthmagicbox.pojo.ConstantData;
import com.easyfun.healthmagicbox.sync.CommCallback;

public class ShareRetrieveInvitedCodeTask extends BaseCommTask implements Runnable{
	String invitecode;
	String personID;
	public ShareRetrieveInvitedCodeTask(Context mcontext, CommCallback ccb,
			String invitecode,String personID) {
		super(mcontext, ccb);

		this.invitecode = invitecode;
		this.personID = personID;
		//invitedCode
		//personID
	}

	@Override
	public void run() {
		JSONObject serializedObj = new JSONObject();
		String result = "";
		try {
			serializedObj.put("invitecode", invitecode);
			serializedObj.put("personID", personID);
			

			Map<String, String> parmas = new HashMap<String, String>();
			parmas.put("jsonstring", serializedObj.toString());
			result = super.uploadByHTTP(parmas, ConstantData.GenerateInvitedcode);
			if (ServerResponseCode.parseOf(result) == ServerResponseCode.FAILED) {

				ccb.setCommResult(this, result,
						ServerResponseCode.FAILED);
			
			}else if (ServerResponseCode.parseOf(result) == ServerResponseCode.SUCCESS) {
				ccb.setCommResult(this, result,
						ServerResponseCode.SUCCESS);
			}else if (result.length()>1)
			{
				ccb.setCommResult(this, result,
						ServerResponseCode.SUCCESS);
			}

		} catch (Exception e) {
			e.printStackTrace();
			ccb.setCommResult(this, result,
					ServerResponseCode.FAILED);
		}
		
	}
	
	

}
